chrome.runtime.onMessage.addListener(({ action, url, type = "webm" }) => {
  console.log("action", action);
  if (action != "download") return;

  const currentDate = new Date();
  const dateString = currentDate.toISOString().slice(0, 10); // 获取格式为 "YYYY-MM-DD" 的日期字符串
  const filename = `record_${dateString}.` + type;

  chrome.downloads.download({
    url,
    filename,
    saveAs: false, // 另存为
    conflictAction: "overwrite",
  });
});
